<!DOCTYPE html>
<!--suppress ALL-->
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('热解析列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>热表型号：</label>
                                <select id="typeId" name="typeId">
                                    <option value="">所有</option>
                                    <option th:each="type:${types}" th:value="${type.typeId}" th:text="${type.typeName}" th:field="${typeId}"></option>
                                </select>
                            </li>

                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="add()" shiro:hasPermission="base:analysis:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="base:analysis:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="base:analysis:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-table-export-js" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('base:analysis:edit')}]];
        var removeFlag = [[${@permission.hasPermi('base:analysis:remove')}]];
        var prefix = ctx + "base/analysis";
        var columnOrder = [[${@dict.getType('column_order')}]];
        var columnHex = [[${@dict.getType('column_hex')}]];
        var columnTime = [[${@dict.getType('column_time')}]];
        var columnCoefficient = [[${@dict.getType('column_coefficient')}]];

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                modalName: "热解析",
                columns: [{
                    checkbox: true
                },

                {
                    field: 'id',
                    title: '主键id',
                    visible: false
                },
                {
                    field: 'type.typeName',
                    title: '热表型号',
                    align:'center'
                },
                {
                    field: 'columnName',
                    title: '字段名称',
                    align:'center'
                },
                {
                    field: 'variableName',
                    title: '变量',
                    align:'center'
                },
                {
                    field: 'columnStart',
                    title: '字段起始位',
                    align:'center'
                },
                {
                    field: 'columnEnd',
                    title: '字段结束位',
                    align:'center'
                },
                {
                    field: 'columnOrder',
                    title: '字段排序',
                    align:'center',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(columnOrder, value);
                    }
                },
                {
                    field: 'columnHex',
                    title: '字段进制',
                    align:'center',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(columnHex, value);
                    }
                },
                {
                    field: 'columnCoefficient',
                    title: '字段系数',
                    align:'center',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(columnCoefficient, value);
                    }
                },
                {
                    field: 'columnUnit',
                    title: '字段单位位置',
                    align:'center'
                },
                {
                    field: 'columnTime',
                    title: '时间是否转换标志',
                    align:'center',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(columnTime, value);
                    }
                },

                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        /* 采集器新增 */
        function add() {
            var typeId = $("#typeId").val();
            if(typeId == ''){
                typeId = 0;
            }
            var url = prefix + '/add/'+typeId;
            $.modal.open("新增", url);
        }
    </script>
</body>
</html>